#!/usr/bin/perl
use DBI;
#tao. ket' noi' den' server 'localhost' user 'root' , pass 'toilatoi' neu' ko ket' noi' duoc. in bao' loi
$dbh = DBI->connect("dbi:mysql:database=php1month;host=localhost;user=root;password=toilatoi") or die "Ko the? ket noi' : $DBI::errstr";
#cau truy van' co so? du~ lieu.
$sSQL = "select * from tb_users";
#chuan? bi. truy van' co so? du~ lieu.
$st = $dbh->prepare($sSQL) or die "Truy van' loi: $DBI::errstr";
#thuc. thi truy van'
$st->execute() or die "Thuc thi truy van loi~ : $DBI::errstr";
#lap. qua cac' hang` ket' qua?
while($row=$st->fetchrow_hashref()){#lenh. fetchrow thanh` cac' hash
	print "Username : $row->{username}\tPassword : $row->{password}\n";
}
